﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ThapCam.Ulti;

/// <summary>
/// Summary description for ThapCamExtession
/// </summary>
/// 
namespace ThapCam.System
{
    public class ThapCamApplication : HttpApplication
    {
        public ThapCamApplication()
            : base()
        {
        }

        private void Application_Start(object sender, EventArgs e)
        {
            ThapCamLogic.createInstance(this);           
        }

        private void Application_End(object sender, EventArgs e)
        {
        }

        private void Application_Error(object sender, EventArgs e)
        {
            Exception exception = Server.GetLastError();            
            HttpException httpException = exception as HttpException;

            if (httpException != null)
            {
                switch (httpException.GetHttpCode())
                {
                    case 404:
                        // page not found
                        LogManager.writeWarning(this.GetType(), "Can not find URL: " + HttpContext.Current.Request.Url.ToString());
                        break;
                    case 500:
                        // server error 
                        LogManager.writeError(this.GetType(), null, httpException);
                        break;                   
                }               
            }
            else
            {
                LogManager.writeError(this.GetType(), null, exception);
            }
        }

        private void Session_Start(object sender, EventArgs e)
        {           
        }

        private void Session_End(object sender, EventArgs e)
        {
        }
       
    }
}